/**
 * 
 */
package com.utility.sqliteDB;

import android.content.ContentValues;
import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteException;
import android.database.sqlite.SQLiteOpenHelper;

/**
 * @author xiaoyff test
 * 
 */
public final class SqliteDBOpenHelper extends SQLiteOpenHelper {

	private final static int VERSION = 1;
	private final static String TABLE_NAME = "Title";
	private final static String TABLE_COL = "id int not null, name varchar(20) not null, age int";
	private final static String CREATE_TABLE = "create table " + TABLE_NAME
			+ "(" + TABLE_COL + ")";
	private final static String DROP_TABLE = "drop table if exists "
			+ TABLE_NAME;

	//

	public SqliteDBOpenHelper(Context context, String dbname,
			SQLiteDatabase.CursorFactory factory, int version) {
		super(context, dbname, factory, version);

	}

	public SqliteDBOpenHelper(Context context, String dbname, int version) {
		this(context, dbname, null, version);

	}

	public SqliteDBOpenHelper(Context context, String dbname,
			ContentValues values) {
		this(context, dbname, VERSION);

	}

	@Override
	public void onCreate(SQLiteDatabase db) {
		try {
			db.execSQL(CREATE_TABLE);
		} catch (SQLiteException e) {
			System.out.println(e.toString());

		} finally {

		}
	}

	@Override
	public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {

		try {
			db.execSQL(DROP_TABLE);
			onCreate(db);
		} catch (SQLiteException e) {
			System.out.println(e.toString());

		} finally {

		}
	}

}
